<?php
	include ("../_conf/constantes.php");
	include ("../config.php");
	require_once (PEARPATH . "HTML/Template/IT.php");
	$tpl = new HTML_Template_IT(TPLPATH);
	$conn = ADONewConnection($dsnComisiones);
	$conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$detComision = "mostrarComision.php";
	$estilo = array();
	$estilo[] = "listado2";
	$estilo[] = "listado1";
	$cont = 1;
	$sql = "SELECT nombredependencia, iddependencia FROM dependencia";
	$sql = "SELECT com.idcomision,
			com.objetocomision,
			com.destino,
			com.entidaddestino,
			com.fechasolicitud,
			COUNT(ce.cedulaempleado) as totalfuncionarios,
			dep.nombredependencia,
			com.rubropres
		FROM comision com,
			comisionempleado ce, 
			dependencia dep
		WHERE com.idcomision = ce.idcomision AND
			dep.iddependencia = com.iddependencia AND
			com.estadocomision <> 'G'
		GROUP BY com.idcomision,
			com.objetocomision,
			com.destino,
			com.entidaddestino,
			com.fechasolicitud,
			dep.nombredependencia,
			com.rubropres
		ORDER BY com.idcomision";
	//var_dump($sql);
	//$rs = $conn->query("SELECT * FROM empleado");
	$rs = $conn->Execute($sql);
	$conn->debug=true
	/*$nmenu = "dependencia";
	$valor = "";
	$default_str = "";
	$itemBlanco = "Selecciones una dependencia";
	$depeSelect = $rs->GetMenu2($nmenu, 
					$default_str,
					$blank1stItem = "$valor:$itemBlanco",
					false,
					0,
					'class="select"');
	$sql = "SELECT idvigencia as codvigencia, idvigencia FROM vigencia";
	$rs = $conn->query($sql);
	$nmenu = "vigencia";
	$valor = "";
	$default_str = "";
	$itemBlanco = "Seleccione vigencia";
	$vigenciaSelect = $rs->GetMenu2($nmenu, 
					$default_str,
					$blank1stItem = "$valor:$itemBlanco",
					false,
					0,
					'class="select"');*/
	$tpl->loadTemplatefile("formListadoComisiones.htm");
	
	while (!$rs->EOF) {
		$tpl->setVariable("ESTILO_FILA", $estilo[$cont%2]);
		$tpl->setVariable("ID_COMISION", $rs->fields["idcomision"]);
		$tpl->setVariable("HREF_COMISION", URLADMIN . $detComision . "?idcomision=" . $rs->fields["idcomision"]);
		$tpl->setVariable("OBJ_COMISION", $rs->fields["objetocomision"]);
		$tpl->setVariable("CIU_DESTINO", $rs->fields["destino"]);
		$tpl->setVariable("ENT_DESTINO", $rs->fields["entidaddestino"]);
		$tpl->setVariable("FECHA_SOLICITUD", $rs->fields["fechasolicitud"]);
		$tpl->setVariable("NUM_FUN", $rs->fields["totalfuncionarios"]);
		$tpl->setVariable("DEPENDENCIA", $rs->fields["nombredependencia"]);
		$tpl->setVariable("RUBROPRES", $rs->fields["rubropres"]);
		$rs->MoveNext();
		$cont++;
		$tpl->parse("row");
	}
	
	$tpl->setVariable("TITULO_PAGINA", "Listado de comisiones");
	$tpl->setVariable("CSSURL", URLCSS);
	//$tpl->setVariable("DEPE_SELECT", $depeSelect);
	//$tpl->setVariable("VIGENCIA_SELECT", $vigenciaSelect);
	$tpl->show();
?>